package com.yao.controller;

import com.yao.model.City;
import com.yao.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CityController {

    @Autowired
    private CityService cityService;

    /**
     * 通过id 查询城市
     * @param id
     * @return
     */
    @RequestMapping("/getCityById")
    public City getCityById(String id){
        if(StringUtils.isEmpty(id)){
            return null;
        }else{
            City city = cityService.selectByPrimaryKey(id);
            System.out.println(city.getCityName());
            return city;
        }
    }
}
